/*
 * 作者: 侯晓宇
 * 时间: 2017-01-11
 * 说明：
 * Copyright (c) 2016-2017 中研沃兮
 */
define(function(require) {

	require("jquery");
	var appInfo = require('app/AppInfo');
	var c = require('app/utils/CommonUtils');
	var UserInfoUtils = require('app/utils/UserInfoUtils');
	var hc = require('app/utils/HttpClientUtils');
	var tip = require('app/utils/TipUtils');
	var action = {};

	var win = window;
	win.user = {};
	
	action.openMyRoomFrm = function() {
		var name = "IndexMeMyRoomWin";
		api.openWin({
			name : name,
			url : './' + name + '.html',
			rect : {
				x : 0,
				y : 0,
				w : api.frameWidth,
				h : api.frameHeight
			},
		});
	}
	
	action.openMyLikeFrm = function() {
		var name = "IndexMeLikeFrm";
		api.openWin({
			name : name,
			url : './' + name + '.html',
			rect : {
				x : 0,
				y : 0,
				w : api.frameWidth,
				h : api.frameHeight
			},
		});
	}
	
	action.openEditInfo = function(){
		var name = "IndividualInfoWin";
		api.openWin({
		    name: name,
		    url: './'+name+'.html',
		    rect:{
		    	x:0,
		    	y:0,
		    	w:api.frameWidth,
		    	h:api.frameHeight
		    },
	    });
	}
	action.openSettingWin = function() {
		var name = "SettingWin";
		api.openWin({
			name : name,
			url : './' + name + '.html',
			rect : {
				x : 0,
				y : 0,
				w : api.frameWidth,
				h : api.frameHeight
			},
		});
	}

	action.getUserInfo = function() {
		//查看UserInfoUtils.js中的getLoginedUser方法
		var user = UserInfoUtils.getLoginedUser();
		win.user = user;
		if (!c.isNull(win.user.userheadimgurl) && win.user.userheadimgurl != '')
			$("#userImage").attr("src", win.user.userheadimgurl);
		if (!c.isNull(win.user.username) && win.user.username != '')
			$("#UserID").html(win.user.username);
	}

	action.followInfo = function() {
		var userid = win.user.userid;
		var url = appInfo.serverbase + "/luyan/user/" + userid + "/followinfo"
		var body = null;
		hc.post(url, body, function(resp) {

			if (resp.status == "200") {
				var data = resp.result;
				//粉丝数、关注数
				//{"followerCount":0,"followingCount":0}}
				$("#followerCount").html(data.followerCount);
				$("#followingCount").html(data.followingCount);
				c.l(data);
			}

		});

	}
	return action;
});
